package com.sense.kukoo.common.wiget.adapter.loadmore;

import android.view.View;
import android.view.ViewGroup;

import com.sense.kukoo.common.wiget.adapter.viewholder.BaseViewHolder;


public abstract class BaseLoadMoreView {
    public abstract View getRootView(ViewGroup parent);
    protected abstract View getLoadingView(BaseViewHolder parent);
    protected abstract View getLoadComplete(BaseViewHolder parent);
    protected abstract View getLoadEndView(BaseViewHolder parent);
    protected abstract View getLoadFailView(BaseViewHolder parent);
    private LoadMoreStatus mLoadMoreStatus = LoadMoreStatus.Complete;
    private long mLastUpdateTime = 0L;

    public LoadMoreStatus getLoadMoreStatus() {
        return mLoadMoreStatus;
    }

    public void setLoadMoreStatus(LoadMoreStatus mLoadMoreStatus) {
        this.mLoadMoreStatus = mLoadMoreStatus;
    }

    public void updateViewStatus(BaseViewHolder viewHolder, int position, LoadMoreStatus loadMoreStatus){
        switch (loadMoreStatus){
            case End:
                getLoadingView(viewHolder).setVisibility(View.GONE);
                getLoadComplete(viewHolder).setVisibility(View.GONE);
                getLoadFailView(viewHolder).setVisibility(View.GONE);
                getLoadEndView(viewHolder).setVisibility(View.VISIBLE);
                break;
            case Fail:
                getLoadingView(viewHolder).setVisibility(View.GONE);
                getLoadComplete(viewHolder).setVisibility(View.GONE);
                getLoadFailView(viewHolder).setVisibility(View.VISIBLE);
                getLoadEndView(viewHolder).setVisibility(View.GONE);
                break;
            case Loading:
                getLoadingView(viewHolder).setVisibility(View.VISIBLE);
                getLoadComplete(viewHolder).setVisibility(View.GONE);
                getLoadFailView(viewHolder).setVisibility(View.GONE);
                getLoadEndView(viewHolder).setVisibility(View.GONE);
                break;
            case Complete:
                getLoadingView(viewHolder).setVisibility(View.GONE);
                getLoadComplete(viewHolder).setVisibility(View.VISIBLE);
                getLoadFailView(viewHolder).setVisibility(View.GONE);
                getLoadEndView(viewHolder).setVisibility(View.GONE);
                break;
        }
    }


}
